package utils;

import java.awt.Image;
import java.util.HashMap;
import java.util.Map;

import javax.imageio.ImageIO;

public class ImageUtil {
	public static Map<String, Image> imageCache = new HashMap<String, Image>();
	public static int currentStyle = 2;
	public static Image getImage(String name){
		Image image =null;
		if(imageCache.containsKey(name)){
			image = imageCache.get(name);
		}else{
			try{
				image = ImageIO.read(ImageUtil.class.getResourceAsStream("/images/style"+currentStyle+"/"+name+".png"));
				imageCache.put(name,image);
			}catch (Exception e) {
				e.printStackTrace();
			}
		}
		return image;
	}
}
